home *** CD-ROM | disk | FTP | other *** search
- #include "lib.h"
-
- /*
- * memccpy - copy bytes up to a certain char
- *
- * CHARBITS should be defined only if the compiler lacks "unsigned char".
- * It should be a mask, e.g. 0377 for an 8-bit machine.
- */
-
- #ifdef NULL
- #undef NULL
- #endif
-
- #define NULL 0
-
- #ifndef CHARBITS
- # define UNSCHAR(c) ((unsigned char)(c))
- # define uchar unsigned char
- #else
- # define UNSCHAR(c) ((c)&CHARBITS)
- # define uchar char
- #endif
-
- _VOIDSTAR
- memccpy(dst, src, ucharstop, size)
- _VOIDSTAR dst;
- _CONST _VOIDSTAR src;
- int ucharstop;
- _SIZET size;
- {
- register char *d;
- register _CONST char *s;
- register _SIZET n;
- register int uc;
-
- if (size <= 0)
- return(NULL);
-
- s = src;
- d = dst;
- uc = UNSCHAR(ucharstop);
- for (n = size; n > 0; n--)
- if (UNSCHAR(*(uchar *)d++ = *(uchar *)s++) == uc)
- return(d);
-
- return(NULL);
- }
-